/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2021并保留所有权利。
 * Copyright 2021, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.jdbcc.onnection;

import java.sql.*;

public class PreDemo {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            conn = DBUtils.getConnection();
            String sql = "insert into animal values (?,?,?)";
            ps = conn.prepareStatement(sql);

            //更改SQL参数
            ps.setInt(1, 6);
            ps.setString(2, "James");
            ps.setInt(3, 24);
            //执行“执行计划”，返回成功更新的行数
            int n = ps.executeUpdate();
            System.out.println(n);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtils.close(rs,ps,conn);
        }
    }

}